//
//  HelpTableViewController.m
//  bitcoin
//
//  Created by caiyajun on 2018/5/8.
//  Copyright © 2018年 比特币. All rights reserved.
//

#import "HelpTableViewController.h"
#import "HelpTableViewCell.h"

@interface HelpTableViewController ()<HelpTableViewCellDelegate>
@property (nonatomic,strong) NSMutableDictionary *linkman1Dic;
@property (nonatomic,strong) NSMutableArray *dataArr;


@end

@implementation HelpTableViewController
-(NSMutableDictionary *)linkman1Dic{
    if(_linkman1Dic == nil){
        _linkman1Dic = [NSMutableDictionary dictionary];
    }
    return _linkman1Dic;
}
- (NSMutableArray *)dataArr {
    if (_dataArr == nil) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.linkman1Dic setValue:@"sdsa" forKey:@"title"];
    [self.linkman1Dic setValue:@"1" forKey:@"selectRow"];
    [self.linkman1Dic setValue:@"NO" forKey:@"isSelect"];
    [self.linkman1Dic setValue:@"来自于加拿大多伦多的Skrumble Network（SKM）旨在搭建一个真正安全的通讯网络，打造全球通讯行业公链和点对点社交区块链社区。目前Skrumble Network已获得20余家全球顶级机构的战略投资；" forKey:@"content"];
    HelpModel *helpModel = [HelpModel mj_objectWithKeyValues:self.linkman1Dic];
    [self.dataArr addObject:helpModel];
    [self.dataArr addObject:helpModel];
    [self.dataArr addObject:helpModel];
    [self.dataArr addObject:helpModel];
    [self.dataArr addObject:helpModel];
    
//    for (int i =0; i<self.dataArr.count; i++) {
//
//        [isOpenArr addObject:@"0"];
//    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.dataArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HelpTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HelpTableViewCell" forIndexPath:indexPath];
    if (cell == nil) {
        cell = [[HelpTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HelpTableViewCell"];
    }
    [cell.clickBtn setImage:[UIImage imageNamed:@"arrowdown-icon"] forState:UIControlStateNormal];
    [cell.clickBtn setImage:[UIImage imageNamed:@"arrowup-icon"] forState:UIControlStateSelected];
    cell.delegate=self;
    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath{
    HelpModel*helpModel=self.dataArr[indexPath.row];
//    CGSize size = [self getSizeWithStr:helpModel.content Width:ScreenWidth-40 Font:14];
    if (helpModel.isSelect) {
//        return size.height+60;
        return 100+60;
    }else{
        return 46;
    }
    
//    return 146;
    
}
#pragma mark - 固定宽度和字体大小，获取label的frame
- (CGSize) getSizeWithStr:(NSString *) str Width:(float)width Font:(float)fontSize
{
    NSDictionary * attribute = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]};
    CGSize tempSize = [str boundingRectWithSize:CGSizeMake(width, MAXFLOAT)
                                        options:NSStringDrawingUsesLineFragmentOrigin
                                     attributes:attribute
                                        context:nil].size;
    return tempSize;
}
- (void)changeBtnClick:(HelpModel *)helpModel{
    [self.tableView reloadData];
}

@end
